package com.maserb.monitor.web.schoolConduct;

import com.maserb.monitor.common.*;
import com.maserb.monitor.entity.UserEntity;
import com.maserb.monitor.entity.schoolConduct.ApplicationRecommendEntity;
import com.maserb.monitor.service.schoolConduct.ApplicationRecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 应用推优手机端
 */
@RestController
@RequestMapping("/applicationApp")
public class ApplicationRecommendAppController {

    @Autowired
    private ApplicationRecommendService service;


    /**
     * 应用推优列表
     * @param name
     * @return
    @RequestMapping("/doListApplication")
    @ResponseBody
    public PageResponseResult<ApplicationRecommendEntity> doListApplication(PageRequestParam page, String name) {
        return AjaxUtils.processPage(page, new Func_T1<Pageable, Page<ApplicationRecommendEntity>>() {
            @Override
            public Page<ApplicationRecommendEntity> invoke(Pageable var1) throws Exception {
                Page<ApplicationRecommendEntity> page = service.findAll(var1,name);
                return page;
            }
        });
    }*/

    /**
     * 根据应用id获取应用详情
     * @param id
     * @return
     */
    @RequestMapping("/getApplication")
    @ResponseBody
    public AjaxResult<ApplicationRecommendEntity> getApplication(String id) {
        return AjaxUtils.process(new Func_T<ApplicationRecommendEntity>() {
            @Override
            public ApplicationRecommendEntity invoke() throws Exception {
                ApplicationRecommendEntity entity = service.findOne(id);
                return entity;
            }
        });
    }

    /**
     * @return
     */
    @RequestMapping("/doListApplication")
    @ResponseBody
    public AjaxResult<List<ApplicationRecommendEntity>> doListApplication() {
        return AjaxUtils.process(new Func_T<List<ApplicationRecommendEntity>>() {
            @Override
            public List<ApplicationRecommendEntity> invoke() throws Exception {
                List<ApplicationRecommendEntity> list = service.findAll();
                return list;
            }
        });
    }

}
